package com.zhx.bussiness.controller;

import com.zhx.business.entity.Order;
import com.zhx.bussiness.params.OrderParams;
import com.zhx.bussiness.service.OrderServiceInf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * describe:
 *
 * @author zhanghaixuan
 * @date 2018/06/14
 **/
@Slf4j
@RestController
@RequestMapping("/v1/order")
public class OrderController {

    @Autowired
    private OrderServiceInf orderService;

    /**
     * 下单
     *
     * @param param
     * @return
     */
    @RequestMapping(value = "/apply", method = RequestMethod.POST)
    public Order apply(@RequestHeader String authId, @RequestHeader String sign, @RequestBody OrderParams param) {
        log.info("申购请求:{}", param);
        Order order = new Order();
        BeanUtils.copyProperties(param,order);
        order = orderService.apply(order);
        log.info("申购结果:{}", order);
        return order;
    }
}
